package my.design.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zp
 * @version 1.0
 * @description: 数据展示面板
 * @date 2022/10/22 16:09
 */
public class DataView {
    private final List<User> userList = new ArrayList<>();

    public DataView(){
        userList.add(new Student("谢⻜机", "重点班", "⼀年⼀班"));
        userList.add(new Student("windy", "重点班", "⼀年⼀班"));
        userList.add(new Student("⼤⽑", "普通班", "⼆年三班"));
        userList.add(new Student("Shing", "普通班", "三年四班"));
        userList.add(new Teacher("BK", "特级教师", "⼀年⼀班"));
        userList.add(new Teacher("娜娜Goddess", "特级教师", "⼀年⼀班"));
        userList.add(new Teacher("dangdang", "普通教师", "⼆年三班"));
        userList.add(new Teacher("泽东", "实习教师", "三年四班"));
    }

    // 展示
    public void show(Visitor visitor) {
        for (User user : userList) {
            user.accept(visitor);
        }
    }
    // 添加老师或者学生
    public void attach(User user){
        userList.add(user);
    }
    // 删除老师或者学生
    public void detach(User user){
        userList.remove(user);
    }
}
